package com.zhongshengnetwork.rightbe.wzt.view;

import android.Manifest;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.zhongshengnetwork.rightbe.Constant.APIKey;
import com.zhongshengnetwork.rightbe.CustomApplication;
import com.zhongshengnetwork.rightbe.MainActivity;
import com.zhongshengnetwork.rightbe.R;
import com.zhongshengnetwork.rightbe.common.AppThemeUtils;
import com.zhongshengnetwork.rightbe.common.CommonUtils;
import com.zhongshengnetwork.rightbe.common.PermissionUtils;
import com.zhongshengnetwork.rightbe.common.ScreenUtils;
import com.zhongshengnetwork.rightbe.common.activity.ReportActivity;
import com.zhongshengnetwork.rightbe.common.customview.ActionSheetDialog;
import com.zhongshengnetwork.rightbe.common.customview.CustomDialog;
import com.zhongshengnetwork.rightbe.common.expandabletextview.ExpandableTextView;
import com.zhongshengnetwork.rightbe.common.utils.ToastUtil;
import com.zhongshengnetwork.rightbe.gsonmodel.WeiShuContentDetailModel;
import com.zhongshengnetwork.rightbe.https.HttpCallBack;
import com.zhongshengnetwork.rightbe.https.HttpsUtils;
import com.zhongshengnetwork.rightbe.lang.activity.SelfImagePreviewActivity;
import com.zhongshengnetwork.rightbe.login.LoginActivity;
import com.zhongshengnetwork.rightbe.wzt.activity.WZTActivity;
import com.zhongshengnetwork.rightbe.wzt.activity.WZTContentActivity;
import com.zhongshengnetwork.rightbe.wzt.activity.WZTContentPublishActivity;

import java.io.File;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import static android.content.Context.CLIPBOARD_SERVICE;
import static com.huantansheng.easyphotos.constant.Code.REQUEST_PERMISSION;

public class WZTOrderRecyclerAdapter extends RecyclerView.Adapter<WZTOrderRecyclerAdapter.ViewHolder>{

    public static final String PACKEGE_GAODE="com.autonavi.minimap";
    public static final String PACKEGE_BAIDU="com.baidu.BaiduMap";
    public static final String PN_TENCENT_MAP = "com.tencent.map"; // 腾讯地图包名
    private List<String> mapList;

    private ClipboardManager myClipboard;

    private List<WeiShuContentDetailModel> list;
    private Byte contentType = 0;
    public boolean canBrowseAll = false;
    private String wztUserId = "";
    private Activity mActivity;
    private RecyclerView listview;
    public Context mContext;
    private static final int maxReadCount = 10;

    private int screenWidth = 0;
    private float density = 0;
    private int imgW = 0;

    public WZTOrderRecyclerAdapter(List<WeiShuContentDetailModel> list, Activity mActivity, RecyclerView listView, Byte contentType, boolean canBrowseAll, String wztUserId){

        this.list = list;
        this.mActivity = mActivity;
        this.mContext = mActivity;
        this.contentType = contentType;
        this.canBrowseAll = canBrowseAll;
        this.wztUserId = wztUserId;
        this.listview = listView;

        this.screenWidth = ScreenUtils.getScreenWidth(mActivity);
        this.density = ScreenUtils.getScreenDensity(mActivity);
        /*
        if (contentType == 2){
            this.imgW = (int) ((this.screenWidth-130*this.density)/3);
        }else {
            this.imgW = (int) ((this.screenWidth-30*this.density)/3);
        }
        */
        this.imgW = (int) ((this.screenWidth-30*this.density)/3);

        myClipboard = (ClipboardManager)this.mActivity.getSystemService(CLIPBOARD_SERVICE);

        initNav();

    }

    static class ViewHolder extends RecyclerView.ViewHolder{

        RelativeLayout wzt_content_layout;

        TextView day_text;
        TextView month_text;
        TextView year_text;
        TextView lang_time;
        ExpandableTextView lang_content;

        LinearLayout up_img_layout;
        ImageView up_img_1;
        FrameLayout up_img_1_layout;
        ImageView up_img_2;
        FrameLayout up_img_2_layout;
        ImageView up_img_3;
        FrameLayout up_img_3_layout;


        LinearLayout middle_img_layout;
        ImageView middle_img_1;
        FrameLayout middle_img_1_layout;
        ImageView middle_img_2;
        FrameLayout middle_img_2_layout;
        ImageView middle_img_3;
        FrameLayout middle_img_3_layout;

        LinearLayout down_img_layout;
        ImageView down_img_1;
        FrameLayout down_img_1_layout;
        ImageView down_img_2;
        FrameLayout down_img_2_layout;
        ImageView down_img_3;
        FrameLayout down_img_3_layout;

        ImageView lang_share_img;
        TextView lang_share_text;
        RelativeLayout lang_share;

        ImageView lang_collect_img;
        TextView lang_collect_text;
        RelativeLayout lang_collect;

        ImageView lang_like_img;
        TextView lang_like_text;
        RelativeLayout lang_like;

        ImageView lang_share_comment;
        TextView lang_comment_text;
        RelativeLayout lang_comment;

        RelativeLayout lang_more;

        LinearLayout menu_item;

        public ViewHolder(View view) {
            super(view);

            wzt_content_layout = (RelativeLayout) view.findViewById(R.id.wzt_content_layout);

            day_text = (TextView) view.findViewById(R.id.day_text);
            month_text = (TextView) view.findViewById(R.id.month_text);
            year_text = (TextView) view.findViewById(R.id.year_text);

            lang_time = (TextView) view.findViewById(R.id.lang_time);
            lang_content = (ExpandableTextView)view.findViewById(R.id.lang_content);

            up_img_layout = (LinearLayout) view.findViewById(R.id.up_img_layout);
            up_img_1 = (ImageView) view.findViewById(R.id.up_img_1);
            up_img_1_layout = (FrameLayout) view.findViewById(R.id.up_img_1_layout);
            up_img_2 = (ImageView) view.findViewById(R.id.up_img_2);
            up_img_2_layout = (FrameLayout) view.findViewById(R.id.up_img_2_layout);
            up_img_3 = (ImageView) view.findViewById(R.id.up_img_3);
            up_img_3_layout = (FrameLayout) view.findViewById(R.id.up_img_3_layout);


            middle_img_layout = (LinearLayout) view.findViewById(R.id.middle_img_layout);
            middle_img_1 = (ImageView) view.findViewById(R.id.middle_img_1);
            middle_img_1_layout = (FrameLayout) view.findViewById(R.id.middle_img_1_layout);
            middle_img_2 = (ImageView) view.findViewById(R.id.middle_img_2);
            middle_img_2_layout = (FrameLayout) view.findViewById(R.id.middle_img_2_layout);
            middle_img_3 = (ImageView) view.findViewById(R.id.middle_img_3);
            middle_img_3_layout = (FrameLayout) view.findViewById(R.id.middle_img_3_layout);

            down_img_layout = (LinearLayout) view.findViewById(R.id.down_img_layout);
            down_img_1 = (ImageView) view.findViewById(R.id.down_img_1);
            down_img_1_layout = (FrameLayout) view.findViewById(R.id.down_img_1_layout);
            down_img_2 = (ImageView) view.findViewById(R.id.down_img_2);
            down_img_2_layout = (FrameLayout) view.findViewById(R.id.down_img_2_layout);
            down_img_3 = (ImageView) view.findViewById(R.id.down_img_3);
            down_img_3_layout = (FrameLayout) view.findViewById(R.id.down_img_3_layout);

            lang_share_img = (ImageView) view.findViewById(R.id.lang_share_img);
            lang_share_text = (TextView) view.findViewById(R.id.lang_share_text);
            lang_share = (RelativeLayout) view.findViewById(R.id.lang_share);

            lang_collect_img = (ImageView) view.findViewById(R.id.lang_collect_img);
            lang_collect_text = (TextView) view.findViewById(R.id.lang_collect_text);
            lang_collect = (RelativeLayout) view.findViewById(R.id.lang_collect);

            lang_like_img = (ImageView) view.findViewById(R.id.lang_like_img);
            lang_like_text = (TextView) view.findViewById(R.id.lang_like_text);
            lang_like = (RelativeLayout) view.findViewById(R.id.lang_like);

            lang_share_comment = (ImageView) view.findViewById(R.id.lang_share_comment);
            lang_comment_text = (TextView) view.findViewById(R.id.lang_comment_text);
            lang_comment = (RelativeLayout) view.findViewById(R.id.lang_comment);

            lang_more = (RelativeLayout) view.findViewById(R.id.lang_more);

            menu_item = (LinearLayout) view.findViewById(R.id.menu_item);
        }

    }

    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.wzt_order_content_item_layout,parent,false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position)
    {
        WeiShuContentDetailModel model = list.get(position);
        String timeS = "";
        boolean isToday = false;
        /*
        if (contentType == 2){
            holder.day_text.setText(model.getDay());
            holder.month_text.setText(model.getMonth()+"月");
            holder.year_text.setText(model.getYear());
            timeS = model.getHour()+":"+model.getMinute();
            if (model.getDay().contains("今日")){
                isToday = true;
            }

            if (position > 0){
                WeiShuContentDetailModel m = list.get(position-1);
                if (model.getDay().equals(m.getDay())){
                    holder.day_text.setVisibility(View.INVISIBLE);
                    holder.month_text.setVisibility(View.INVISIBLE);
                    holder.year_text.setVisibility(View.INVISIBLE);
                }else {
                    holder.day_text.setVisibility(View.VISIBLE);
                    holder.month_text.setVisibility(View.VISIBLE);
                    holder.year_text.setVisibility(View.VISIBLE);
                }
            }else {
                holder.day_text.setVisibility(View.VISIBLE);
                holder.month_text.setVisibility(View.VISIBLE);
                holder.year_text.setVisibility(View.VISIBLE);
            }
        }
        */

        String timeStr = model.getTime();
        if (!CommonUtils.isEmpty(timeS)){
            timeStr = timeS;
        }
        if (model.getOriginal() == true){
            timeStr = "原创 · "+model.getTime();
            if (!CommonUtils.isEmpty(timeS)){
                timeStr = "原创 · "+ timeS;
            }
        }
        if (!CommonUtils.isEmpty(model.getLocation())){
            timeStr += (" · " + model.getLocation());
        }
        holder.lang_time.setText(timeStr);
        holder.lang_time.setTag(position);
        holder.lang_time.setClickable(true);
        holder.lang_time.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onClickLocation((int)view.getTag());
            }
        });

        holder.lang_content.setText(model.getTitle(),position);

        holder.up_img_layout.setVisibility(View.GONE);
        holder.middle_img_layout.setVisibility(View.GONE);
        holder.down_img_layout.setVisibility(View.GONE);
        int width = imgW;
        if (isToday == true){
            width -= 10*density;
        }
        if (model.getImglist() == null){

        }else if (model.getImglist().size() == 1){
            holder.up_img_layout.setVisibility(View.VISIBLE);
            holder.up_img_1.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setTag(position+",1");
            holder.up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            ViewGroup.LayoutParams params = holder.up_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_1.setLayoutParams(params);

            Glide.with(mActivity).load(model.getImglist().get(0)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_1);
            holder.up_img_2_layout.setVisibility(View.INVISIBLE);
            holder.up_img_2.setVisibility(View.INVISIBLE);
            params = holder.up_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_2.setLayoutParams(params);
            holder.up_img_3.setVisibility(View.INVISIBLE);
            holder.up_img_3_layout.setVisibility(View.INVISIBLE);
            params = holder.up_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_3.setLayoutParams(params);

        }else if (model.getImglist().size() == 2){
            holder.up_img_layout.setVisibility(View.VISIBLE);
            holder.up_img_1.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setTag(position+",1");
            holder.up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            ViewGroup.LayoutParams params = holder.up_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(0)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_1);

            holder.up_img_2.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setTag(position+",2");
            holder.up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(1)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_2);
            holder.up_img_3.setVisibility(View.INVISIBLE);
            holder.up_img_3_layout.setVisibility(View.INVISIBLE);

        }else if (model.getImglist().size() == 3){
            holder.up_img_layout.setVisibility(View.VISIBLE);
            holder.up_img_1.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setTag(position+",1");
            holder.up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            ViewGroup.LayoutParams params = holder.up_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(0)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_1);

            holder.up_img_2.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setTag(position+",2");
            holder.up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(1)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_2);

            holder.up_img_3.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setTag(position+",3");
            holder.up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(2)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_3);

        }else if (model.getImglist().size() == 4){
            holder.up_img_layout.setVisibility(View.VISIBLE);
            holder.up_img_1.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setTag(position+",1");
            holder.up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            ViewGroup.LayoutParams params = holder.up_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(0)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_1);

            holder.up_img_2.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setTag(position+",2");
            holder.up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(1)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_2);

            holder.up_img_3.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setTag(position+",3");
            holder.up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(2)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_3);

            holder.middle_img_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setTag(position+",4");
            holder.middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(3)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_1);
            holder.middle_img_2.setVisibility(View.INVISIBLE);
            holder.middle_img_2_layout.setVisibility(View.INVISIBLE);
            holder.middle_img_3.setVisibility(View.INVISIBLE);
            holder.middle_img_3_layout.setVisibility(View.INVISIBLE);

        }else if (model.getImglist().size() == 5){
            holder.up_img_layout.setVisibility(View.VISIBLE);
            holder.up_img_1.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setTag(position+",1");
            holder.up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            ViewGroup.LayoutParams params = holder.up_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(0)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_1);

            holder.up_img_2.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setTag(position+",2");
            holder.up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(1)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_2);

            holder.up_img_3.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setTag(position+",3");
            holder.up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(2)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_3);

            holder.middle_img_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setTag(position+",4");
            holder.middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(3)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_1);
            holder.middle_img_2.setVisibility(View.VISIBLE);
            holder.middle_img_2_layout.setVisibility(View.VISIBLE);
            holder.middle_img_2_layout.setTag(position+",5");
            holder.middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(4)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_2);
            holder.middle_img_3.setVisibility(View.INVISIBLE);
            holder.middle_img_3_layout.setVisibility(View.INVISIBLE);

        }else if (model.getImglist().size() == 6){
            holder.up_img_layout.setVisibility(View.VISIBLE);
            holder.up_img_1.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setTag(position+",1");
            holder.up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            ViewGroup.LayoutParams params = holder.up_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(0)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_1);

            holder.up_img_2.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setTag(position+",2");
            holder.up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(1)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_2);

            holder.up_img_3.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setTag(position+",3");
            holder.up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(2)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_3);

            holder.middle_img_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setTag(position+",4");
            holder.middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(3)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_1);
            holder.middle_img_2.setVisibility(View.VISIBLE);
            holder.middle_img_2_layout.setVisibility(View.VISIBLE);
            holder.middle_img_2_layout.setTag(position+",5");
            holder.middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(4)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_2);
            holder.middle_img_3.setVisibility(View.VISIBLE);
            holder.middle_img_3_layout.setVisibility(View.VISIBLE);
            holder.middle_img_3_layout.setTag(position+",6");
            holder.middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(5)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_3);

        }else if (model.getImglist().size() == 7){
            holder.up_img_layout.setVisibility(View.VISIBLE);
            holder.up_img_1.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setTag(position+",1");
            holder.up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            ViewGroup.LayoutParams params = holder.up_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(0)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_1);

            holder.up_img_2.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setTag(position+",2");
            holder.up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(1)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_2);

            holder.up_img_3.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setTag(position+",3");
            holder.up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(2)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_3);

            holder.middle_img_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setTag(position+",4");
            holder.middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(3)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_1);
            holder.middle_img_2.setVisibility(View.VISIBLE);
            holder.middle_img_2_layout.setVisibility(View.VISIBLE);
            holder.middle_img_2_layout.setTag(position+",5");
            holder.middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(4)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_2);
            holder.middle_img_3.setVisibility(View.VISIBLE);
            holder.middle_img_3_layout.setVisibility(View.VISIBLE);
            holder.middle_img_3_layout.setTag(position+",6");
            holder.middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(5)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_3);

            holder.down_img_layout.setVisibility(View.VISIBLE);
            holder.down_img_1.setVisibility(View.VISIBLE);
            holder.down_img_1_layout.setVisibility(View.VISIBLE);
            holder.down_img_1_layout.setTag(position+",7");
            holder.down_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.down_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.down_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(6)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.down_img_1);
            holder.down_img_2.setVisibility(View.INVISIBLE);
            holder.down_img_2_layout.setVisibility(View.INVISIBLE);
            holder.down_img_3.setVisibility(View.INVISIBLE);
            holder.down_img_3_layout.setVisibility(View.INVISIBLE);
        }else if (model.getImglist().size() == 8){
            holder.up_img_layout.setVisibility(View.VISIBLE);
            holder.up_img_1.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setTag(position+",1");
            holder.up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            ViewGroup.LayoutParams params = holder.up_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(0)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_1);

            holder.up_img_2.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setTag(position+",2");
            holder.up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(1)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_2);

            holder.up_img_3.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setTag(position+",3");
            holder.up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(2)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_3);

            holder.middle_img_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setTag(position+",4");
            holder.middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(3)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_1);
            holder.middle_img_2.setVisibility(View.VISIBLE);
            holder.middle_img_2_layout.setVisibility(View.VISIBLE);
            holder.middle_img_2_layout.setTag(position+",5");
            holder.middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(4)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_2);
            holder.middle_img_3.setVisibility(View.VISIBLE);
            holder.middle_img_3_layout.setVisibility(View.VISIBLE);
            holder.middle_img_3_layout.setTag(position+",6");
            holder.middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(5)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_3);

            holder.down_img_layout.setVisibility(View.VISIBLE);
            holder.down_img_1.setVisibility(View.VISIBLE);
            holder.down_img_1_layout.setVisibility(View.VISIBLE);
            holder.down_img_1_layout.setTag(position+",7");
            holder.down_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.down_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.down_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(6)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.down_img_1);
            holder.down_img_2.setVisibility(View.VISIBLE);
            holder.down_img_2_layout.setVisibility(View.VISIBLE);
            holder.down_img_2_layout.setTag(position+",8");
            holder.down_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.down_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.down_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(7)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.down_img_2);
            holder.down_img_3.setVisibility(View.INVISIBLE);
            holder.down_img_3_layout.setVisibility(View.INVISIBLE);
        }else if (model.getImglist().size() == 9){
            holder.up_img_layout.setVisibility(View.VISIBLE);
            holder.up_img_1.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setVisibility(View.VISIBLE);
            holder.up_img_1_layout.setTag(position+",1");
            holder.up_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            ViewGroup.LayoutParams params = holder.up_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(0)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_1);

            holder.up_img_2.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setVisibility(View.VISIBLE);
            holder.up_img_2_layout.setTag(position+",2");
            holder.up_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(1)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_2);

            holder.up_img_3.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setVisibility(View.VISIBLE);
            holder.up_img_3_layout.setTag(position+",3");
            holder.up_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.up_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.up_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(2)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.up_img_3);

            holder.middle_img_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setVisibility(View.VISIBLE);
            holder.middle_img_1_layout.setTag(position+",4");
            holder.middle_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(3)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_1);
            holder.middle_img_2.setVisibility(View.VISIBLE);
            holder.middle_img_2_layout.setVisibility(View.VISIBLE);
            holder.middle_img_2_layout.setTag(position+",5");
            holder.middle_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(4)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_2);
            holder.middle_img_3.setVisibility(View.VISIBLE);
            holder.middle_img_3_layout.setVisibility(View.VISIBLE);
            holder.middle_img_3_layout.setTag(position+",6");
            holder.middle_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.middle_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.middle_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(5)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.middle_img_3);

            holder.down_img_layout.setVisibility(View.VISIBLE);
            holder.down_img_1.setVisibility(View.VISIBLE);
            holder.down_img_1_layout.setVisibility(View.VISIBLE);
            holder.down_img_1_layout.setTag(position+",7");
            holder.down_img_1_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.down_img_1.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.down_img_1.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(6)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.down_img_1);
            holder.down_img_2.setVisibility(View.VISIBLE);
            holder.down_img_2_layout.setVisibility(View.VISIBLE);
            holder.down_img_2_layout.setTag(position+",8");
            holder.down_img_2_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.down_img_2.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.down_img_2.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(7)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.down_img_2);
            holder.down_img_3.setVisibility(View.VISIBLE);
            holder.down_img_3_layout.setVisibility(View.VISIBLE);
            holder.down_img_3_layout.setTag(position+",9");
            holder.down_img_3_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            params = holder.down_img_3.getLayoutParams();
            params.width =width;
            params.height = width;
            holder.down_img_3.setLayoutParams(params);
            Glide.with(mActivity).load(model.getImglist().get(8)+CommonUtils.formatString(model.getImgEnd())).placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).dontAnimate().into(holder.down_img_3);

        }

        if (model.getSharecount() == 0){
            holder.lang_share_text.setText("分享");
        }else {
            holder.lang_share_text.setText(CommonUtils.getDisplayCount(model.getSharecount()));
        }

        if (model.isCollected() == true){
            holder.lang_collect_img.setImageResource(R.drawable.collection_sel);
            holder.lang_collect_text.setTextColor(ContextCompat.getColor(mContext,R.color.lightGreenColor));
        }else {
            holder.lang_collect_img.setImageResource(R.drawable.collection);
            holder.lang_collect_text.setTextColor(AppThemeUtils.getInstance().getSmallTextColor());
        }
        if (model.getCollectcount() == 0){
            holder.lang_collect_text.setText("收藏");
        }else {
            holder.lang_collect_text.setText(CommonUtils.getDisplayCount(model.getCollectcount()));
        }

        if (model.isLike() == true){
            holder.lang_like_img.setImageResource(R.drawable.workgroup_img_like_sel);
            holder.lang_like_text.setTextColor(ContextCompat.getColor(mContext,R.color.lightGreenColor));
        }else {
            holder.lang_like_img.setImageResource(R.drawable.workgroup_img_like);
            holder.lang_like_text.setTextColor(AppThemeUtils.getInstance().getSmallTextColor());
        }
        if (model.getLikecount() == 0){
            holder.lang_like_text.setText("喜欢");
        }else {
            holder.lang_like_text.setText(CommonUtils.getDisplayCount(model.getLikecount()));
        }

        if (model.getCommentcount() == 0){     holder.lang_comment_text.setText("评论"); }else {     holder.lang_comment_text.setText(CommonUtils.getDisplayCount(model.getCommentcount())); }

        holder.lang_share.setTag(position);
        holder.lang_share.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickShare((int)v.getTag(),v);
            }
        });

        holder.lang_collect.setTag(position);
        holder.lang_collect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickCollect((int)v.getTag());
            }
        });

        holder.lang_like.setTag(position);
        holder.lang_like.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickLike((int)v.getTag());
            }
        });

        holder.lang_comment.setTag(position);
        holder.lang_comment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickDetail((int)v.getTag());
            }
        });

        holder.lang_more.setTag(position);
        holder.lang_more.setClickable(true);
        holder.lang_more.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickMore((int)v.getTag());
            }
        });

        holder.lang_time.setVisibility(View.INVISIBLE);
        holder.menu_item.setVisibility(View.GONE);
    }

    @Override
    public int getItemCount() {
        if (list != null && list.size() > maxReadCount && canBrowseAll == false){
            return maxReadCount;
        }
        return list.size();
    }

    //点击图片处理
    private void onClickImageView(final View view){
        if (list == null || list.size() == 0){
            return;
        }

        if (this.mActivity == null){
            return;
        }

        if (CustomApplication.isWatchingImg == true){
            return;
        }
        CustomApplication.isWatchingImg = true;

        String tag = view.getTag().toString();
        List<String> l = CommonUtils.stringToArrayList(tag);
        WeiShuContentDetailModel model = list.get(Integer.valueOf(l.get(0)));
        int position = Integer.valueOf(l.get(1))-1;


        Intent intent = new Intent(this.mActivity, SelfImagePreviewActivity.class);
        intent.putExtra("position",position);
        intent.putExtra("isListImg",true);
        intent.putExtra("imgs",model.getImg());
        //View代表方法传入的控件
        int[] viewLocation = new int[2];
        view.getLocationInWindow(viewLocation);
        int viewX = viewLocation[0]; // x 坐标
        int viewY = viewLocation[1]-(int) (20*ScreenUtils.getScreenDensity(CustomApplication.mContext)); // y 坐标，这里当顶部有状态栏时，要减去状态栏的高度
        intent.putExtra("viewX",viewX);
        intent.putExtra("viewY",viewY);
        intent.putExtra("imgW",imgW);
        intent.putExtra("imgH",imgW);
        this.mActivity.startActivity(intent);
        this.mActivity.overridePendingTransition(0,0);//可以通过参数设置关闭与要显示的动画效果,0表示无效果.

    }

    //点击删除
    private void onClickDelete(final int position){
        if (this.mActivity == null){
            return;
        }
        if (list == null || list.size() == 0){
            return;
        }
        if (CommonUtils.isLogin() == false){
            Intent intent = new Intent(this.mActivity, LoginActivity.class);
            this.mActivity.startActivity(intent);
            return;
        }

        CustomDialog dialog = null;
        final CustomDialog.Builder builder = new CustomDialog.Builder(this.mActivity);
        builder.setTitle("温馨提示");
        builder.setMessage("确定要删除？");
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                deleteIndex(position);
            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        dialog = builder.create();
        dialog.show();
    }
    private void deleteIndex(final int position){
        if (list == null || list.size() == 0){
            return;
        }
        WeiShuContentDetailModel model = list.get(position);
        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
        map.put("dataId", model.getLangid());
        String url = "weishu/content/delete.do";

        list.remove(position);
        notifyDataSetChanged();
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
            }

            @Override
            public void onError(String msg) {
            }
        });
    }

    //点击了详情
    private void onClickDetail(int position){
        if (this.mActivity == null){
            return;
        }
        if (list == null || list.size() == 0){
            return;
        }
        WeiShuContentDetailModel model = list.get(position);
        Intent intent = new Intent(this.mActivity, WZTContentActivity.class);
        Bundle bundle=new Bundle();
        bundle.putSerializable("model", model);//序列化
        intent.putExtras(bundle);//发送数据
        this.mActivity.startActivity(intent);
    }

    //点击了分享
    private void onClickShare(int position, View v){
        if (this.mActivity == null){
            return;
        }
        if (list == null || list.size() == 0){
            return;
        }
        final WeiShuContentDetailModel model = list.get(position);
        Intent intent = new Intent(this.mActivity, WZTContentActivity.class);
        Bundle bundle=new Bundle();
        bundle.putSerializable("model", model);//序列化
        bundle.putBoolean("share",true);
        intent.putExtras(bundle);//发送数据
        this.mActivity.startActivity(intent);

    }

    //笔芯了收藏
    private void onClickCollect(final int position){
        if (this.mActivity == null){
            return;
        }
        if (list == null || list.size() == 0){
            return;
        }
        if (CommonUtils.isLogin() == false){
            Intent intent = new Intent(this.mActivity,LoginActivity.class);
            this.mActivity.startActivity(intent);
            return;
        }
        final WeiShuContentDetailModel model = list.get(position);
        if (model.isCollected() == true){
            return;
        }
        model.setCollected(true);
        model.setCollectcount(model.getCollectcount()+1);
        //list.set(position,model);
        //notifyDataSetChanged();
        //updateItem(position);
        //update(position, this.listview);
        notifyItemChanged(position);

        new Thread(){
            @Override
            public void run() {
                super.run();
                final HashMap<String, String> map = new HashMap<String, String>();
                map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
                map.put("sourceid", model.getLangid());
                map.put(APIKey.typeKey,"2");
                String url = "miniapp/"+"langappid"+"/addcollection.do";
                HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                    @Override
                    public void onSuccess(String data) {
                        Log.e("TAG","收藏结果："+data);
                    }

                    @Override
                    public void onError(String msg) {
                    }
                });
            }
        }.start();
    }

    //点击了笔芯
    private void onClickLike(final int position){
        if (this.mActivity == null){
            return;
        }
        if (list == null || list.size() == 0){
            return;
        }
        if (CommonUtils.isLogin() == false){
            Intent intent = new Intent(this.mActivity,LoginActivity.class);
            this.mActivity.startActivity(intent);
            return;
        }
        final WeiShuContentDetailModel model = list.get(position);
        if (model.isLike() == true){
            return;
        }
        model.setLike(true);
        model.setLikecount(model.getLikecount()+1);
        //list.set(position,model);
        //notifyDataSetChanged();
        //update(position, this.listview);
        notifyItemChanged(position);

        new Thread(){
            @Override
            public void run() {
                super.run();
                final HashMap<String, String> map = new HashMap<String, String>();
                map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
                map.put("id", model.getLangid());
                String url = "weishu/content/like.do";
                HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                    @Override
                    public void onSuccess(String data) {
                        Log.e("TAG","笔芯结果："+data);
                    }

                    @Override
                    public void onError(String msg) {
                    }
                });
            }
        }.start();
    }

    //举报
    private void report(String reportId, int reportType){//reportType:1-举报人；2-举报微句；3-举报评论；4-举报微纸条；5-举报微纸条内容；6-举报微纸条评论
        if (CommonUtils.isLogin() == false){
            Intent intent = new Intent(this.mActivity,LoginActivity.class);
            this.mActivity.startActivity(intent);
            return;
        }
        Intent intent = new Intent(this.mActivity, ReportActivity.class);
        intent.putExtra(APIKey.idKey,reportId);
        intent.putExtra(APIKey.typeKey,reportType);
        this.mActivity.startActivity(intent);
    }

    //点击了更多
    private void onClickMore(final int position){
        if (this.mActivity == null){
            return;
        }
        if (list == null || list.size() == 0){
            return;
        }
        final WeiShuContentDetailModel model = list.get(position);
        final List<String> menu = new ArrayList<String>();
        if (CommonUtils.isLogin() == false || (model.getUserid().equals(CustomApplication.loginModel.getUid()) == false && wztUserId.equals(CustomApplication.loginModel.getUid()) == false)){
            //复制、举报、详情
            menu.add("复制");
            menu.add("详情");
            menu.add("举报");
        }else {
            //复制、编辑、删除
            menu.add("编辑");
            menu.add("详情");
            menu.add("复制");
            menu.add("删除");
        }
        ActionSheetDialog actionSheetDialog = new ActionSheetDialog(this.mActivity)
                .builder()
                .setTitle("请选择")
                .setCancelable(false)
                .setCanceledOnTouchOutside(true);
        for (String s : menu){
            actionSheetDialog.addSheetItem(s, null, new ActionSheetDialog.OnSheetItemClickListener() {
                @Override
                public void onClick(int which) {
                    if (which > 0){
                        String title = menu.get(which-1);
                        if (title.equals("复制")){
                            onClickCopy(model.getTitle());
                        }else if (title.equals("详情")){
                            onClickDetail(position);
                        }else if (title.equals("举报")){
                            report(model.getLangid(), 5);
                        }else if (title.equals("编辑")){
                            onClickEdit(model);
                        }else if (title.equals("删除")){
                            onClickDelete(position);
                        }
                    }
                }
            });
        }
        actionSheetDialog.show();

    }

    //复制
    private void onClickCopy(String text){
        try{
            ClipData myClip = ClipData.newPlainText("text", text);
            myClipboard.setPrimaryClip(myClip);
            Toast.makeText(this.mActivity.getApplicationContext(), "内容已复制~",
                    Toast.LENGTH_SHORT).show();
        }catch (Exception e){

        }
    }

    //编辑
    private void onClickEdit(WeiShuContentDetailModel model){
        Intent intent = new Intent(this.mActivity, WZTContentPublishActivity.class);
        Bundle bundle=new Bundle();
        bundle.putSerializable("model", model);//序列化
        intent.putExtras(bundle);//发送数据
        this.mActivity.startActivityForResult(intent, WZTActivity.REQUEST_CONTENT_EDIT);
    }

    //位置信息
    private void onClickLocation(final int position)
    {
        if (this.mActivity == null){
            return;
        }
        if (list == null || list.size() == 0){
            return;
        }

        final WeiShuContentDetailModel model = list.get(position);
        if (CommonUtils.isEmpty(model.getLocation())){
            return;
        }
        if (mapList == null || mapList.size() == 0){
            return;
        }
        ActionSheetDialog actionSheetDialog = new ActionSheetDialog(this.mActivity)
                .builder()
                .setTitle("请选择")
                .setCancelable(false)
                .setCanceledOnTouchOutside(true);
        for (String s : mapList){
            actionSheetDialog.addSheetItem(s, null, new ActionSheetDialog.OnSheetItemClickListener() {
                @Override
                public void onClick(int which) {
                    if (which > 0){
                        String title = mapList.get(which-1);
                        if (title.equals("高德地图")){
                            gaodeNav(model.getCity(),model.getLocation(),model.getLatitude()+"",model.getLongtitude()+"");
                        }else if (title.equals("百度地图")){
                            baiduNav(model.getCity(),model.getLocation(),model.getLatitude()+"",model.getLongtitude()+"");
                        }else if (title.equals("腾讯地图")){
                            openTencentMap(mContext, 0, 0, null, model.getLatitude(), model.getLongtitude(), model.getLocation());
                        }
                    }
                }
            });
        }
        actionSheetDialog.show();
    }

    //以下是导航相关
    private void initNav(){
        if (mapList == null){
            mapList = new ArrayList<String>();
        }
        if (mapList.size() == 0){
            if (isInstallByread(PACKEGE_GAODE)){
                mapList.add("高德地图");
            }
            if(isInstallByread(PACKEGE_BAIDU)){
                mapList.add("百度地图");
            }
            if (isInstallByread(PN_TENCENT_MAP)){
                mapList.add("腾讯地图");
            }
        }
    }


    /**
     * 判断是否安装目标应用
     * @param packageName 目标应用安装后的包名
     * @return 是否已安装目标应用
     */
    private boolean isInstallByread(String packageName) {
        return new File("/data/data/" + packageName).exists();
    }

    /**
     * 城市名 位置名  目的地纬度 目的地经度
     */
    private void baiduNav(String city, String position,String lat,String lon) {
        Intent intent = new Intent();
        // 驾车路线规划
        intent.setData(Uri.parse("baidumap://map/direction?"+"origin="+CustomApplication.latitude+","+CustomApplication.longtitude+"&region="+city+"&destination="+position+"&mode=driving"));//walking
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        this.mActivity.startActivity(intent);
        //对局部细节进行了优化。
    }

    //高德导航
    private void gaodeNav(String city, String position,String lat,String lon){
        try {
            Intent intent=Intent.parseUri("androidamap://viewMap?sourceApplication=appname&poiname="+position+"&lat="+lat+"&lon="+lon+"&dev=0",0);;
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            this.mActivity.startActivity(intent);
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }


    /**
     * 打开腾讯地图
     * params 参考http://lbs.qq.com/uri_v1/guide-route.html
     *
     * @param context
     * @param slat 起点纬度
     * @param slon 起点经度
     * @param sname 起点名称 可不填（0,0，null）
     * @param dlat 终点纬度
     * @param dlon 终点经度
     * @param dname 终点名称 必填
     * 驾车：type=drive，policy有以下取值
    0：较快捷
    1：无高速
    2：距离
    policy的取值缺省为0
     * &from=" + dqAddress + "&fromcoord=" + dqLatitude + "," + dqLongitude + "
     */
    public static void openTencentMap(Context context, double slat, double slon, String sname, double dlat, double dlon, String dname) {
        String uriString = null;
        StringBuilder builder = new StringBuilder("qqmap://map/routeplan?type=drive&policy=0&referer=zhongshuo");
        if (slat != 0) {
            builder.append("&from=").append(sname)
                    .append("&fromcoord=").append(slat)
                    .append(",")
                    .append(slon);
        }
        builder.append("&to=").append(dname)
                .append("&tocoord=").append(dlat)
                .append(",")
                .append(dlon);
        uriString = builder.toString();
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setPackage(PN_TENCENT_MAP);
        intent.setData(Uri.parse(uriString));
        context.startActivity(intent);
    }

    /**
     * 数据更新时刷新单个item
     * @param position 当前item在listview中的position
     * @param lv 当前listview
     */
    public void update(int position, NestedListView lv) {
        int firstVisiblePosition = lv.getFirstVisiblePosition();
        //获取对应item的View对象
        View view = lv.getChildAt(position - firstVisiblePosition);
        ViewHolder holder = (ViewHolder) view.getTag();
        WeiShuContentDetailModel model = list.get(position);
        if (model.getSharecount() == 0){
            holder.lang_share_text.setText("分享");
        }else {
            holder.lang_share_text.setText(CommonUtils.getDisplayCount(model.getSharecount()));
        }

        if (model.isCollected() == true){
            holder.lang_collect_img.setImageResource(R.drawable.collection_sel);
            holder.lang_collect_text.setTextColor(ContextCompat.getColor(mContext,R.color.lightGreenColor));
        }else {
            holder.lang_collect_img.setImageResource(R.drawable.collection);
            holder.lang_collect_text.setTextColor(AppThemeUtils.getInstance().getSmallTextColor());
        }
        if (model.getCollectcount() == 0){
            holder.lang_collect_text.setText("收藏");
        }else {
            holder.lang_collect_text.setText(CommonUtils.getDisplayCount(model.getCollectcount()));
        }

        if (model.isLike() == true){
            holder.lang_like_img.setImageResource(R.drawable.workgroup_img_like_sel);
            holder.lang_like_text.setTextColor(ContextCompat.getColor(mContext,R.color.lightGreenColor));
        }else {
            holder.lang_like_img.setImageResource(R.drawable.workgroup_img_like);
            holder.lang_like_text.setTextColor(AppThemeUtils.getInstance().getSmallTextColor());
        }
        if (model.getLikecount() == 0){
            holder.lang_like_text.setText("喜欢");
        }else {
            holder.lang_like_text.setText(CommonUtils.getDisplayCount(model.getLikecount()));
        }

        if (model.getCommentcount() == 0){     holder.lang_comment_text.setText("评论"); }else {     holder.lang_comment_text.setText(CommonUtils.getDisplayCount(model.getCommentcount())); }

    }

    //以下是拖曳排序
    /**
     * 对拖拽的元素进行排序
     * @param fromPosition
     * @param toPosition
     */
    void itemMove(int fromPosition, int toPosition) {
        if (fromPosition < toPosition) {
            for (int i = fromPosition; i < toPosition; i++) {
                Collections.swap(list, i, i + 1);
            }
        } else {
            for (int i = fromPosition; i > toPosition; i--) {
                Collections.swap(list, i, i - 1);
            }
        }
        notifyItemMoved(fromPosition, toPosition);
    }


}
